package com.estate.web.controller.system;

import com.estate.common.annotation.Log;
import com.estate.common.config.SysConfig;
import com.estate.common.core.controller.BaseController;
import com.estate.common.core.domain.AjaxResult;
import com.estate.common.enums.BusinessType;
import com.estate.common.utils.file.FileUploadUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/system/file")
public class SysFileController extends BaseController {


    @Log(title = "File Upload", businessType = BusinessType.INSERT)
    @PostMapping("/upload")
    public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception {
        String url = FileUploadUtils.upload(SysConfig.getUploadPath(), file);
        return AjaxResult.success("Operation successful", url);
    }

}
